package com.hok.misc.jdbc;

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;

public class ProcedureTest {
	public static void main(String[] args) throws Exception {
		exec2();
	}

	private static void exec1() throws Exception {
		Class.forName("oracle.jdbc.driver.OracleDriver");
		Connection con = DriverManager.getConnection("jdbc:oracle:thin:@//10.10.141.209:1521/shzw1", "md", "Uiop246!");
		System.out.println("con:"+con);
		String call = "{call test_out (?,?)}";
		CallableStatement proc = con.prepareCall(call);
		proc.setString(1, "UD");
		proc.registerOutParameter("out_msg",  java.sql.Types.VARCHAR);
		boolean flag = proc.execute();
		System.out.println(flag);
		System.out.println(proc.getString("out_msg"));
	}
	//
	private static void exec2() throws Exception {
		Class.forName("oracle.jdbc.driver.OracleDriver");
		Connection con = DriverManager.getConnection("jdbc:oracle:thin:@//10.10.10.121:1521/oel1210", "md", "md");
		con.prepareStatement("select sysdate from dual");
		System.out.println(con);
		String call = "{call test_out (?,?)}";
		CallableStatement proc = con.prepareCall(call);
		proc.setString(1, "UD");
		proc.registerOutParameter(2,  java.sql.Types.VARCHAR);
		boolean flag = proc.execute();
		System.out.println(flag);
		System.out.println(proc.getString(2));
	}
}
